{extend name="base" /} {block name="body"}
<div class="layui-body">
	<div class="navbar">
		<a><cite>新闻管理</cite></a>&nbsp;<span class="layui-box">&gt;</span>
	</div>
	<!--tab标签-->
	
				
			
			<!--<a class="layui-btn layui-btn-status page-btns" href="{:url('status',['table'=>'goods','val'=>1,'id_name'=>'goods_id','field'=>'is_on_sale'])}"><i class="fa fa-check-circle-o"></i> 上架</a>
			<a class="layui-btn layui-btn-danger page-btns" href="{:url('status',['table'=>'goods','val'=>2,'id_name'=>'goods_id','field'=>'is_on_sale'])}"><i class="fa fa-ban"></i> 下架</a>-->
		</blockquote>
		</form>
		<a class="layui-btn  layui-btn-normal" href='add' >添加新闻</a>
		
		<div class="layui-tab-content">
			<table class="layui-table layui-form">
				<thead>
					<tr>
						
                        <th class="text-center">标题</th>
                        <th class='text-center'>分类</th>
                        <th class="text-center">点击量</th>
                        <th class="text-center">发布时间</th>
                        <th class='text-center'>操作</th>
					</tr>
				</thead>
				<tbody>
					<form id="listForm">
						{foreach name="list" item="vo"}
						<tr>
						
							<td>{$vo.title}</td>
							<td>{$vo.name}</td>
							<td>{$vo.clock}</td>
							<td>{$vo.add_time} </td>
							<td>  
								<a href="update?id={$vo.id}" class="layui-btn layui-btn-small"><i class="fa fa-edit"></i> 编辑</a>
								<a onclick="del('{$vo.id}')" class="layui-btn  layui-btn-error layui-btn-small">删除</a>
						</tr>
						{/foreach}
					</form>
				</tbody>
			</table>
               {$list->render()}
		</div>
	</div>
</div>
{/block}
{block name="js"}
  <script src="/public/static/layui/layui.js" charset="utf-8"></script>
  <script>
  function del(obj) {
		layer.confirm('确认要删除吗?', {
		  btn: ['确认', '取消'],//可以无限个按钮,
		}, function(index){
			$.ajax({
				type:"post",
				url: "{:url('news/delete')}",
				data: {id :obj},//表单数据
				success: function(data) {
					layer.msg(data.msg,function(index){
						location.href=data.url;
						
						
					});
					
				}
			});
		  
		});
	
			}
  	</script>
{/block}